---
title: "Bats and human blood project: median cell sizes"
output:
  html_document:
    df_print: paged
  pdf_document: default
---


# prepare
```{r}
pathWD <- "~/Documents/08_Pojekte/01_dRT-DC/220301_Bob_DataAnalysis_BatsHumans/20230829_AnimalTypeTempSexAnalysis"
setwd(pathWD)
```


# load data space image
```{r}
load(file.path(pathWD, paste0("RDataSpace_v8", ".RData")))
```

# find meadian cell sizes and corresponding cells
```{r}
for (iter.AnimalType in levels.AnimalType) {
  print(paste0("Species = ", iter.AnimalType, ":"))
  tbl.AnimalType <- combTable[combTable$animalType == iter.AnimalType, ]
  medianArea <- median(tbl.AnimalType$area)
  print(paste0("Median cell size = ", medianArea, " um^2"))
  print("Cells:")
  tbl.medAreaCells <- tbl.AnimalType[tbl.AnimalType$area == medianArea, c("dateCode","tempLevel","measNum","cellNum","area","velocity","tau1","tau2","deltaDefoTau1","deltaDefoTau2","eModulus","viscosity")]
  print(tbl.medAreaCells)
  write.csv(tbl.medAreaCells, file.path(pathWD, paste0("tbl", "_medianArea", iter.AnimalType, ".csv")), row.names = FALSE)
  print("")
}
rm(tbl.AnimalType,medianArea)
```

